home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / cgazv4n2.zip / GETSP.ASM < prev    next >
Assembly Source File  |  1989-10-23  |  2KB  |  88 lines

  1. ; ************************************************************
  2. ;
  3. ; getsp.asm - returns current value of SP in AX.  Note that
  4. ;             this value is *not* adjusted for the bytes that
  5. ;             were pushed onto the stack by the call to getsp.
  6. ;             This introduces such a small error that it's
  7. ;             not worth the extra code.
  8. ;
  9. ; Author: John Rex
  10. ; Assembler: MASM
  11. ; Memory models: any may be used.  Tell the assembler which is
  12. ;    needed by defining mem_s, mem_c, mem_m, mem_l, or mem_h
  13. ;
  14. ; Usage: unsigned getsp();
  15. ;
  16. ; ************************************************************
  17.  
  18. tell1 MACRO message
  19. if1
  20. %out message
  21. endif
  22. endm
  23.  
  24. ifdef mem_s     ;small model?
  25.   mem_Small equ 1
  26.   .model small
  27.   tell1 <Assembling Small Model>
  28. else
  29.   mem_Small equ 0
  30. endif
  31.  
  32. ifdef mem_c     ;compact model?
  33.   mem_Compact equ 1
  34.   .model compact
  35.   tell1 <Assembling Compact Model>
  36. else
  37.   mem_Compact equ 0
  38. endif
  39.  
  40. ifdef mem_m     ;medium model?
  41.   mem_Medium equ 1
  42.   .model medium
  43.   tell1 <Assembling Medium Model>
  44. else
  45.   mem_Medium equ 0
  46. endif
  47.  
  48. ifdef mem_h     ;Huge model?
  49.   mem_l equ 1   ;looks like large model
  50. endif
  51.  
  52. ifdef mem_l     ;Large model?
  53.   mem_Large equ 1
  54.   .model large
  55.   ifndef mem_h
  56.     tell1 <Assembling Large Model>
  57.   else
  58.     tell1 <Assembling Large/Huge Model>
  59.   endif
  60. else
  61.   mem_Large equ 0
  62. endif
  63.  
  64. ; now check model
  65. mem_Model = mem_Small + mem_Compact + mem_Medium + mem_Large
  66.  
  67. if mem_Model ne 1
  68.   .err                  ; no good!
  69.   tell1 <Must define one of mem_s, mem_c, mem_m, or mem_l to pick a memory model>
  70. endif
  71.  
  72. ; After all of the above, the code is rather anti-climactic
  73.  
  74.         .code
  75.  
  76.         public  _getsp
  77.  
  78. _getsp  proc
  79.         mov     ax,sp
  80.     ret
  81. _getsp  endp
  82.  
  83.         end
  84.  
  85.  
  86.  
  87.  
  88.